package cn.birdbaby.plugins.sync.methodsyner;

import cn.birdbaby.plugins.constants.Constants;
import cn.birdbaby.plugins.sync.AbstractSyncer;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * @author llorando 13/8/24 11:14 am
 */
public abstract class AbstractMethodSyncer extends AbstractSyncer {

    @Override
    public void sync(PsiClass psiClass) {
        PsiClass destination = findClass(psiClass);
        if (Objects.isNull(destination)) return;
        List<PsiElement> psiMethods = filterPsiElement(List.of(psiClass.getMethods()), List.of(destination.getMethods()));
        addPsiElement(destination, psiMethods);
    }

    @Override
    public String getElementName(PsiElement element) {
        return ((PsiMethod) element).getName();
    }

}
